package br.com.comanda.webservice.resources;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import br.com.comanda.webservice.business.BoardBusiness;
import br.com.comanda.webservice.model.Board;

@Path("/boards")
public class BoardResources {

	private final BoardBusiness boardBusiness = new BoardBusiness();

	@GET
	@Produces({ MediaType.APPLICATION_JSON })
	public List<Board> getBoards() {
		return this.boardBusiness.findAll();
	}

	@Path("{id}")
	@GET
	@Produces({ MediaType.APPLICATION_JSON })
	public Board getBoard(@PathParam("id") Long id) {
		return this.boardBusiness.findById(id);
	}

	@POST
	@Consumes({ MediaType.APPLICATION_JSON })
	@Produces({ MediaType.TEXT_HTML })
	public String addBoard(Board board) {
		this.boardBusiness.save(board);
		return "ok";
	}

}
